package utils;

import org.springframework.ui.Model;

public class ViewMessages {
	public static void addSuccessMessage(Model model, String message) {
		model.addAttribute("successMessage", message);
	}

	public static void addErrorMessage(Model model, String message) {
		model.addAttribute("errorMessage", message);
	}
	
	public static String getErrorPage(){
		return "/common/errorView";
	}
	
	public static String getSuccessPage(){
		return "/common/successView";
	}
	
	public static String getErrorPageAndSetMessage(Model model, String message){
		addErrorMessage(model, message);
		return getErrorPage();
	}
	
	public static String getSuccessPageAndSetMessage(Model model, String message){
		addSuccessMessage(model, message);
		return getSuccessPage();
	}
}
